<?php

declare(strict_types=1);


use Hyperf\HttpServer\Router\Router;

// service fitness heartbeat
Router::get('/heartbeat', function () {
    return 'success';
});

Router::addGroup(
    '',
    function () {
        //发送手机验证码【phone：手机号码】
        Router::addRoute(['POST'], '/sendSmsCaptcha', 'App\Controller\CommonController@sendSmsCaptcha');
        Router::addRoute(['get'], '/syncEarnings', 'App\Controller\CommonController@syncEarnings');

        // 测试上传路由
        Router::addRoute(['post'], '/upload', 'App\Controller\UploadController@upload');
        Router::addRoute(['get'], '/view/{id}', 'App\Controller\UploadController@view');
    }
);


/**
 * 母公司后台
 */
Router::addGroup(
    '/admin',
    function () {
        //登录
        Router::addRoute('post', '/login', 'App\Controller\Admin\AdminUserController@login');

        //合作商-获取图片验证码
        Router::addRoute('get', '/captcha', 'App\Controller\Cooperative\CooperativeUserController@captcha');

        Router::addRoute('get', '/init', '\App\Controller\CommonController@init');

        Router::addGroup(
            '',
            function () {
                // 上传图片
                Router::addRoute(['post'], '/upload', 'App\Controller\UploadController@upload');
                //查看图片
                Router::addRoute(['get'], '/view/{id}', 'App\Controller\UploadController@view');

                //用户管理-列表
                Router::addRoute('get', '/users', 'App\Controller\Admin\UserController@index');
                //用户管理-封号
                Router::addRoute('put', '/users/{userId}/block', 'App\Controller\Admin\UserController@block');
                //用户管理-解封
                Router::addRoute('put', '/users/{userId}/unblock', 'App\Controller\Admin\UserController@unblock');
                //悬赏主管理-列表
                Router::addRoute('get', '/userEmployers', 'App\Controller\Admin\UserEmployerController@index');
                //悬赏主管理-封号
                Router::addRoute('put', '/userEmployers/{userEmployerId}/block', 'App\Controller\Admin\UserEmployerController@block');
                //悬赏主管理-解封
                Router::addRoute('put', '/userEmployers/{userEmployerId}/unblock', 'App\Controller\Admin\UserEmployerController@unblock');
                //悬赏主管理-添加
                Router::addRoute('post', '/userEmployers', 'App\Controller\Admin\UserEmployerController@create');
                //悬赏主管理-设置金额
                Router::addRoute('put', '/userEmployers/{userEmployerId}/setBalance', 'App\Controller\Admin\UserEmployerController@setBalance');
                //企业实名审核-列表
                Router::addRoute('get', '/certificationCompanyApply', 'App\Controller\Admin\CertificationCompanyApplyController@index');
                //企业实名审核-通过
                Router::addRoute('put', '/certificationCompanyApply/{certificationCompanyApplyId}/allow', 'App\Controller\Admin\CertificationCompanyApplyController@allow');
                //企业实名审核-不通过
                Router::addRoute('put', '/certificationCompanyApply/{certificationCompanyApplyId}/notAllow', 'App\Controller\Admin\CertificationCompanyApplyController@notAllow');
                //任务审核-列表
                Router::addRoute('get', '/taskAudits', 'App\Controller\Admin\TaskController@auditIndex');
                //任务审核-通过
                Router::addRoute('put', '/tasks/{taskId}/allow', 'App\Controller\Admin\TaskController@allow');
                //任务审核-不通过
                Router::addRoute('put', '/tasks/{taskId}/notAllow', 'App\Controller\Admin\TaskController@notAllow');
                //任务-详情
                Router::addRoute('get', '/tasks/{taskId}', 'App\Controller\Admin\TaskController@info');
                //任务管理-列表
                Router::addRoute('get', '/tasks', 'App\Controller\Admin\TaskController@index');
                //任务管理-冻结
                Router::addRoute('put', '/tasks/{taskId}/block', 'App\Controller\Admin\TaskController@block');
                //任务管理-解冻
                Router::addRoute('put', '/tasks/{taskId}/unblock', 'App\Controller\Admin\TaskController@unblock');
                //提现管理-提现列表
                Router::addRoute('get', '/userWithDraws', 'App\Controller\Admin\UserWithDrawController@index');
                //提现管理-确认
                Router::addRoute('put', '/userWithDraws/{userWithDrawId}/confirm', 'App\Controller\Admin\UserWithDrawController@confirm');
                //提现管理-驳回
                Router::addRoute('put', '/userWithDraws/{userWithDrawId}/reject', 'App\Controller\Admin\UserWithDrawController@reject');
                //提现管理-打款
                Router::addRoute('put', '/userWithDraws/{userWithDrawId}/transfer', 'App\Controller\Admin\UserWithDrawController@transfer');
                //财务-用户提现流水
//                Router::addRoute('get', '/userWithDrawLogs', 'App\Controller\Admin\UserWithDrawController@userWithDrawLogs');
//                //财务-用户提现流水导出。eg：http://127.0.0.1:9501/admin/userWithDrawExport?date=2020-07-01
//                Router::addRoute('get', '/userWithDrawExport', 'App\Controller\Admin\UserWithDrawController@userWithDrawExport');

                //商机-推送记录
                Router::addRoute('get', '/taskPushes', 'App\Controller\Admin\TaskPushController@index');
                //商机-任务列表
                Router::addRoute('get', '/taskPushes/tasks', 'App\Controller\Admin\TaskPushController@taskIndex');
                //商机-推送商机
                Router::addRoute('post', '/taskPushes/push', 'App\Controller\Admin\TaskPushController@push');

                //运营管理-列表
                Router::addRoute('get', '/adminUsers', 'App\Controller\Admin\AdminUserController@index');
                //运营管理-添加人员
                Router::addRoute('post', '/adminUsers', 'App\Controller\Admin\AdminUserController@save');
                //运营管理-修改人员
                Router::addRoute('put', '/adminUsers/{id}', 'App\Controller\Admin\AdminUserController@save');
                //运营管理-删除人员
                Router::addRoute('delete', '/adminUsers/{id}', 'App\Controller\Admin\AdminUserController@delete');
                //运营管理-角色列表（分页）
                Router::addRoute('get', '/adminRoles', 'App\Controller\Admin\AdminRoleController@index');
                //运营管理-角色列表（全部）
                Router::addRoute('get', '/adminRoles/all', 'App\Controller\Admin\AdminRoleController@all');
                //运营管理-添加角色
                Router::addRoute('post', '/adminRoles', 'App\Controller\Admin\AdminRoleController@save');
                //运营管理-修改角色
                Router::addRoute('put', '/adminRoles/{id}', 'App\Controller\Admin\AdminRoleController@save');
                //运营管理-删除角色
                Router::addRoute('delete', '/adminRoles/{id}', 'App\Controller\Admin\AdminRoleController@delete');
                //运营管理-获取角色菜单
                Router::addRoute('get', '/adminRoles/{id}/adminMenus', 'App\Controller\Admin\AdminRoleController@menus');
                //运营管理-菜单列表(树形)
                Router::addRoute('get', '/adminMenus/tree', 'App\Controller\Admin\AdminMenuController@tree');
                //合作商管理-合作商列表
                Router::addRoute('get', '/cooperatives', 'App\Controller\Admin\CooperativeController@index');
                //合作商管理-冻结合作商
                Router::addRoute('get', '/cooperatives/{cooperativeId}/block', 'App\Controller\Admin\CooperativeController@block');
                //合作商管理-解冻合作商
                Router::addRoute('get', '/cooperatives/{cooperativeId}/unblock', 'App\Controller\Admin\CooperativeController@unblock');
                //合作商管理-获取合作商权限
                Router::addRoute('get', '/cooperatives/{id}/menus', 'App\Controller\Admin\CooperativeController@getMenus');
                //合作商管理-修改合作商权限
                Router::addRoute('put', '/cooperatives/{id}/menus', 'App\Controller\Admin\CooperativeController@setMenus');
                //合作商管理-全部权限（tree）
                Router::addRoute('get', '/cooperatives/menuTree', 'App\Controller\Admin\CooperativeController@menusTree');
                //运营管理-操作日志
                Router::addRoute('get', '/showLog', 'App\Controller\Admin\AdminUserController@showOperationLog');

                //运营数据-汇总
                Router::addRoute('get', '/statistics', 'App\Controller\Admin\StatisticsController@index');
                //运营数据-柱状图
                Router::addRoute('post', '/barChart', 'App\Controller\Admin\StatisticsController@barChart');

                //财务-用户提现流水
                Router::addRoute('get', '/withdrawList', 'App\Controller\Admin\FinanceController@WithdrawList');
                //财务-平台抽成流水
                Router::addRoute('get', '/percentageList', 'App\Controller\Admin\FinanceController@PercentageList');
                //财务-悬赏主充值流水
                Router::addRoute('get', '/rechargeList', 'App\Controller\Admin\FinanceController@RechargeList');
                //财务-流水导出
                Router::addRoute('get', '/logExport', 'App\Controller\Admin\FinanceController@LogExport');

                //通知-列表
                Router::addRoute('get', '/notification', 'App\Controller\Admin\NotificationController@index');
                //通知-标记已读
                Router::addRoute('post', '/notification/read', 'App\Controller\Admin\NotificationController@read');

                //获取省市列表
                Router::addRoute('get', '/regions', '\App\Controller\CommonController@regions');
                //根据城市获取合作商
                Router::addRoute('get', '/cooperList', 'App\Controller\Admin\PublicCommonController@regionCoopers');

                /** =================================== 合作商资料审核 ===================================== */
                Router::addRoute('get', '/cooperativeAudits', 'App\Controller\Admin\CooperativeController@auditIndex');
                Router::addRoute('put', '/cooperatives/{id}/audit', 'App\Controller\Admin\CooperativeController@audit');
                Router::addRoute('put', '/cooperatives/{id}/submitAudit', 'App\Controller\Admin\CooperativeController@submitAudit');
                //微信Api证书下载
                Router::addRoute('get','/downloadApi/{id}','App\Controller\admin\CooperativeController@downloadApi');

            },
            [
                'middleware' => [\App\Middleware\AdminAuthMiddleware::class]
            ]
        );
    }
);

/**
 * 运营商后台
 */
Router::addGroup(
    '/cooperative',
    function () {
        //合作商-登录
        Router::addRoute('post', '/login', 'App\Controller\Cooperative\CooperativeUserController@login');
        //合作商-获取图片验证码
        Router::addRoute('get', '/captcha', 'App\Controller\Cooperative\CooperativeUserController@captcha');
        //合作商-注册
        Router::addRoute('post', '/register', 'App\Controller\Cooperative\CooperativeController@register');
        //授权成功后的回调
        Router::addRoute(['get', 'post'], '/bindWxMp/{cooperativeId}', 'App\Controller\Cooperative\CooperativeController@bindWxMp');
        //省市列表
        Router::addRoute('get', '/regions', '\App\Controller\CommonController@regions');

        Router::addGroup('', function () {
            //上传图片
            Router::addRoute(['post'], '/upload', 'App\Controller\UploadController@upload');
            //主页-获取小程序授权二维码链接
            Router::addRoute('get', '/wxPreAuthUrl', 'App\Controller\Cooperative\CooperativeController@preAuthUrl');
            //主页-绑定微信商户号信息
            Router::addRoute('post', '/bindWxMerchant', 'App\Controller\Cooperative\CooperativeController@bindWxMerchant');
            //主页-获取当前用户信息
            Router::addRoute('get', '/cooperativeUsers/me', 'App\Controller\Cooperative\CooperativeUserController@me');
            //主页-修改当前用户信息
            Router::addRoute('put', '/cooperativeUsers/me', 'App\Controller\Cooperative\CooperativeUserController@saveMe');
            //主页-审核催促
            Router::addRoute('get', '/taskExecs/urgeIndex', 'App\Controller\Cooperative\TaskExecController@urgeIndex');
            //操作人员管理-列表
            Router::addRoute('get', '/cooperativeUsers', 'App\Controller\Cooperative\CooperativeUserController@index');
            //操作人员管理-添加
            Router::addRoute('post', '/cooperativeUsers', 'App\Controller\Cooperative\CooperativeUserController@save');
            //操作人员管理-修改
            Router::addRoute('put', '/cooperativeUsers/{id}', 'App\Controller\Cooperative\CooperativeUserController@save');
            //操作人员管理-删除
            Router::addRoute('delete', '/cooperativeUsers/{id}', 'App\Controller\Cooperative\CooperativeUserController@delete');
            //操作人员管理-角色列表（分页）
            Router::addRoute('get', '/cooperativeRoles', 'App\Controller\Cooperative\CooperativeRoleController@index');
            //操作人员管理-角色列表（全部）
            Router::addRoute('get', '/cooperativeRoles/all', 'App\Controller\Cooperative\CooperativeRoleController@all');
            //操作人员管理-添加角色
            Router::addRoute('post', '/cooperativeRoles', 'App\Controller\Cooperative\CooperativeRoleController@save');
            //操作人员管理-修改角色
            Router::addRoute('put', '/cooperativeRoles/{id}', 'App\Controller\Cooperative\CooperativeRoleController@save');
            //操作人员管理-删除角色
            Router::addRoute('delete', '/cooperativeRoles/{id}', 'App\Controller\Cooperative\CooperativeRoleController@delete');
            //操作人员管理-角色权限
            Router::addRoute('get', '/cooperativeRoles/{id}/menus', 'App\Controller\Cooperative\CooperativeRoleController@menus');
            //操作人员管理-所有权限(tree)
            Router::addRoute('get', '/cooperativeRoles/menuTree', 'App\Controller\Cooperative\CooperativeRoleController@menuTree');
            //配置中心-标签列表
            Router::addRoute('get', '/taskTags', 'App\Controller\Cooperative\TaskTagController@index');
            //配置中心-添加标签
            Router::addRoute('post', '/taskTags', 'App\Controller\Cooperative\TaskTagController@save');
            //配置中心-修改标签
            Router::addRoute('put', '/taskTags/{id}', 'App\Controller\Cooperative\TaskTagController@save');
            //配置中心-删除标签
            Router::addRoute('delete', '/taskTags/{id}', 'App\Controller\Cooperative\TaskTagController@delete');
            //配置中心-类型列表
            Router::addRoute('get', '/taskTypes', 'App\Controller\Cooperative\TaskTypeController@index');
            //配置中心-添加类型
            Router::addRoute('post', '/taskTypes', 'App\Controller\Cooperative\TaskTypeController@save');
            //配置中心-修改类型
            Router::addRoute('put', '/taskTypes/{id}', 'App\Controller\Cooperative\TaskTypeController@save');
            //配置中心-删除类型
            Router::addRoute('delete', '/taskTypes/{id}', 'App\Controller\Cooperative\TaskTypeController@delete');
            //配置中心-banner列表
            Router::addRoute('get', '/configBanners', 'App\Controller\Cooperative\ConfigBannerController@index');
            //配置中心-添加banner
            Router::addRoute('post', '/configBanners', 'App\Controller\Cooperative\ConfigBannerController@create');
            //配置中心-修改banner
            Router::addRoute('put', '/configBanners/{id}', 'App\Controller\Cooperative\ConfigBannerController@update');
            //配置中心-删除banner
            Router::addRoute('delete', '/configBanners/{id}', 'App\Controller\Cooperative\ConfigBannerController@delete');
            //配置中心-隐藏banner
            Router::addRoute('post', '/configBanners/block', 'App\Controller\Cooperative\ConfigBannerController@block');
            //配置中心-显示banner
            Router::addRoute('post', '/configBanners/unblock', 'App\Controller\Cooperative\ConfigBannerController@unblock');
            //配置中心-发现页列表
            Router::addRoute('get', '/configDiscovers', 'App\Controller\Cooperative\ConfigDiscoverController@index');
            //配置中心-添加发现页
            Router::addRoute('post', '/configDiscovers', 'App\Controller\Cooperative\ConfigDiscoverController@create');
            //配置中心-修改发现页
            Router::addRoute('put', '/configDiscovers/{id}', 'App\Controller\Cooperative\ConfigDiscoverController@update');
            //配置中心-删除发现页
            Router::addRoute('delete', '/configDiscovers/{id}', 'App\Controller\Cooperative\ConfigDiscoverController@delete');

            //配置中心-其他设置修改
            Router::addRoute('put', '/configOthers/{name}', 'App\Controller\Cooperative\ConfigOtherController@save');
            //配置中心-其他设置列表
            Router::addRoute('get', '/configOthers', 'App\Controller\Cooperative\ConfigOtherController@index');

            //用户管理-列表
            Router::addRoute('get', '/users', 'App\Controller\Cooperative\UserController@index');
            //用户管理-封号
            Router::addRoute('put', '/users/{userId}/block', 'App\Controller\Cooperative\UserController@block');
            //用户管理-解封
            Router::addRoute('put', '/users/{userId}/unblock', 'App\Controller\Cooperative\UserController@unblock');
            //悬赏主管理-列表
            Router::addRoute('get', '/userEmployers', 'App\Controller\Cooperative\UserEmployerController@index');
            //悬赏主管理-封号
            Router::addRoute('put', '/userEmployers/{userEmployerId}/block', 'App\Controller\Cooperative\UserEmployerController@block');
            //悬赏主管理-解封
            Router::addRoute('put', '/userEmployers/{userEmployerId}/unblock', 'App\Controller\Cooperative\UserEmployerController@unblock');
            //悬赏主管理-添加
            Router::addRoute('post', '/userEmployers', 'App\Controller\Cooperative\UserEmployerController@create');
            //悬赏主管理-设置金额
            Router::addRoute('put', '/userEmployers/{userEmployerId}/setBalance', 'App\Controller\Cooperative\UserEmployerController@setBalance');
            //任务审核-列表
            Router::addRoute('get', '/taskAudits', 'App\Controller\Cooperative\TaskController@auditIndex');
            //任务审核-通过
            Router::addRoute('put', '/taskAudits/{taskId}/allow', 'App\Controller\Cooperative\TaskController@allow');
            //任务审核-不通过
            Router::addRoute('put', '/taskAudits/{taskId}/notAllow', 'App\Controller\Cooperative\TaskController@notAllow');
            //任务管理-列表
            Router::addRoute('get', '/tasks', 'App\Controller\Cooperative\TaskController@index');
            //任务管理-冻结
            Router::addRoute('put', '/tasks/{taskId}/block', 'App\Controller\Cooperative\TaskController@block');
            //任务管理-解冻
            Router::addRoute('put', '/tasks/{taskId}/unblock', 'App\Controller\Cooperative\TaskController@unblock');
            //仲裁-列表
            Router::addRoute('get', '/taskExecs', 'App\Controller\Cooperative\TaskExecController@index');
            //仲裁-用户胜诉
            Router::addRoute('put', '/taskExecs/{taskExecId}/userWin', 'App\Controller\Cooperative\TaskExecController@userWin');
            //仲裁-悬赏主胜诉
            Router::addRoute('put', '/taskExecs/{taskExecId}/employerWin', 'App\Controller\Cooperative\TaskExecController@employerWin');
            //操作人员管理-查看操作日志
            Router::addRoute('get', '/showLog', 'App\Controller\Cooperative\CooperativeUserController@operateLog');
            //运营数据
            Router::addRoute('get', '/statistics', 'App\Controller\Cooperative\StatisticsController@index');
            //运营数据-柱状图
            Router::addRoute('post', '/barChart', 'App\Controller\Cooperative\StatisticsController@barChart');
            //财务-悬赏主充值流水
            Router::addRoute('get', '/rechargeList', 'App\Controller\Cooperative\FinanceController@RechargeList');
            //财务-用户提现流水
            Router::addRoute('get', '/withdrawList', 'App\Controller\Cooperative\FinanceController@WithdrawList');
            //财务-平台抽成流水
            Router::addRoute('get', '/percentageList', 'App\Controller\Cooperative\FinanceController@PercentageList');
            //财务-流水导出
            Router::addRoute('get', '/financeExport', 'App\Controller\Cooperative\FinanceController@LogExport');
            //提现管理-列表
            Router::addRoute('get', '/cashList', 'App\Controller\Cooperative\WithdrawalCashController@cashList');
            //提现管理-确认
            Router::addRoute('get', '/ack', 'App\Controller\Cooperative\WithdrawalCashController@ackApply');
            //提现管理-驳回
            Router::addRoute('post', '/reject', 'App\Controller\Cooperative\WithdrawalCashController@rejectApply');
            //提现管理-已打款
            Router::addRoute('get', '/paid', 'App\Controller\Cooperative\WithdrawalCashController@paidApply');
            //操作人员管理-是否客服
            Router::addRoute('get', '/setCust/{id}', 'App\Controller\Cooperative\CooperativeUserController@setIsCust');

            //商机-列表
            Router::addRoute('get', '/taskPushes', 'App\Controller\Cooperative\TaskPushController@index');
            //微信API证书上传
            Router::addRoute('post', '/uploadApi', 'App\Controller\Cooperative\CooperativeController@uploadApi');
            //获取合作商信息
            Router::addRoute('get', '/info', 'App\Controller\Cooperative\CooperativeController@cooperativeInfo');
            //任务详情
            Router::addRoute('get', '/taskInfo/{taskId}', 'App\Controller\Cooperative\TaskController@taskInfo');
            //获取系统消息列表(未读)
            Router::addRoute('get','/noticeList','App\Controller\Cooperative\NoticeController@UnreadList');
            //设置消息已读
            Router::addRoute('post','/setRead','App\Controller\Cooperative\NoticeController@SetRead');
            //获取活动、任务页筛选列表（点击Banner图跳转）
            Router::addRoute('get','/jumpLink/{type}','App\Controller\Cooperative\ConfigBannerController@JumpLink');
        }, ['middleware' => [
            \App\Middleware\CooperativeAuthMiddleware::class
        ]]);
    }
);

Router::addGroup(
    '/wx',
    function () {
        Router::addRoute(['get', 'post'], '/auth', 'App\Controller\Api\Wechat\OpenPlatformController@auth');
        Router::addRoute(['get'], '/templateList', 'App\Controller\Api\Wechat\OpenPlatformController@templateList');
        Router::addRoute(['get', 'post'], '/notice/{appID}', 'App\Controller\Api\Wechat\OpenPlatformController@notice');
        Router::addRoute(['get', 'post'], '/authCode', 'App\Controller\Api\Wechat\OpenPlatformController@authCode');
        Router::addRoute(['get', 'post'], '/info', 'App\Controller\Api\Wechat\OpenPlatformController@info');
        Router::addRoute(['get', 'post'], '/login', 'App\Controller\Api\Wechat\OpenPlatformController@login');
        Router::addRoute(['get', 'post'], '/preAuthUrl', 'App\Controller\Api\Wechat\OpenPlatformController@preAuthUrl');
        Router::addRoute(['get', 'post'], '/qrcode', 'App\Controller\Api\Wechat\OpenPlatformController@getQrCode');
        Router::addRoute(['get', 'post'], '/pay', 'App\Controller\Api\Wechat\OpenPlatformController@pay');
    }
);


/**
 * IM聊天
 */
Router::addGroup(
    '/im',
    function () {
        Router::addGroup(
            '',
            function () {
                //获取GoEasy访问Key
                Router::addRoute('get', '/getOtp', 'App\Controller\Im\CommonContronller@AllocationKey');
                //创建会话记录
                Router::addRoute('post', '/imchat', 'App\Controller\Im\CommonContronller@CreateImChat');
                //获取会话列表
                Router::addRoute('get', '/imList', 'App\Controller\Im\ImUserListController@messageList');
                //删除会话记录
                Router::addRoute('get', '/delIm/{id}', 'App\Controller\Im\ImUserListController@delete');
                //保存聊天信息记录
                Router::addRoute('post', '/newMessage', 'App\Controller\Im\ImUserListController@newMessage');
                //获取聊天信息历史
                Router::addRoute('get', '/messageLog', 'App\Controller\Im\ImUserListController@messageLog');
                //im聊天文件上传（目前只限上传图片）
                Router::addRoute('post', '/uploadFile', 'App\Controller\UploadController@upload');
                //获取客服列表
                Router::addRoute('get', '/customerList', 'App\Controller\Im\ImUserListController@getCustomerList');
                //聊天框获取用户信息
                Router::addRoute('get', '/userInfo', 'App\Controller\Im\ImUserListController@UserInfo');
            }, [
                'middleware' => [
                    \App\Middleware\ImAuthMiddleware::class,
                ],
            ]
        );
    }

);


require BASE_PATH . '/config/routes/client_v1.php';